package com.ncu.sports.controller;

import com.alibaba.fastjson.JSON;
import com.ncu.sports.pojo.MMenu;
import com.ncu.sports.pojo.Msg;
import com.ncu.sports.service.MMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.jws.Oneway;
import java.util.HashMap;
import java.util.List;

@RestController
public class MMenuController {

    @Autowired
    private MMenuService mMenuService;

    @RequestMapping("mMenu")
    public String getMMenu(){
        List<MMenu> mMenu = mMenuService.getMMenu();
        Msg msg=new Msg();
        HashMap<Object, Object> map=new HashMap<>();
        if(mMenu.size()<=0){
            msg.setFlag(0);
            msg.setMsg("操作错误");
            map.put("mMenu",null);
            msg.setData(map);
        }else {
            msg.setFlag(1);
            msg.setMsg("操作成功");
            map.put("mMenu",mMenu);
            msg.setData(map);
        }
        String data = JSON.toJSONString(msg);
        return data;
    }
}
